﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace PloobsEngine.SceneControl
{
    public class DepthCueingPostEffect : IPostEffect
    {

        Effect effect = null;        
        EngineStuff engine;                
        
        public void Draw(IRenderHelper rHelper,  Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {
             effect.Parameters["Z_Near"].SetValue(world.ActiveCamera.NearPlane);
             effect.Parameters["Z_Far"].SetValue(world.ActiveCamera.FarPlane);
             effect.Parameters["depth"].SetValue(rHelper[PrincipalConstants.dephRT]);
             effect.Parameters["color"].SetValue(rHelper[PrincipalConstants.CurrentImage]);
             effect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(world.ActiveCamera.View * world.ActiveCamera.Projection));
             effect.Parameters["halfPixel"].SetValue(EngineStuff.HalfPixel);
             effect.Parameters["cameraPosition"].SetValue(world.ActiveCamera.Position);                

             rHelper.RenderTextureToFullScreenVertexPixel(effect);             
         
        }

        public void init(EngineStuff engine)
        {
            effect = EngineStuff.InternalContentManager.GetAsset<Effect>("CuingDepth");            
            this.engine = engine;            

        }

    }
}


